<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionController::SessionManagement::ClassMethods</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionController::SessionManagement::ClassMethods</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/actionpack/lib/action_controller/session_management_rb.html">
                vendor/rails/actionpack/lib/action_controller/session_management.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000890">session</a>&nbsp;&nbsp;
      <a href="#M000891">session=</a>&nbsp;&nbsp;
      <a href="#M000889">session_options</a>&nbsp;&nbsp;
      <a href="#M000888">session_store</a>&nbsp;&nbsp;
      <a href="#M000887">session_store=</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000890" class="method-detail">
        <a name="M000890"></a>

        <div class="method-heading">
          <a href="#M000890" class="method-signature">
          <span class="method-name">session</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Specify how sessions ought to be managed for a subset of the actions on the
controller. Like filters, you can specify <tt>:only</tt> and
<tt>:except</tt> clauses to restrict the subset, otherwise options apply to
all actions on this controller.
</p>
<p>
The <a href="ClassMethods.html#M000890">session</a> options are
inheritable, as well, so if you specify them in a parent controller, they
apply to controllers that extend the parent.
</p>
<p>
Usage:
</p>
<pre>
  # turn off session management for all actions.
  session :off

  # turn off session management for all actions _except_ foo and bar.
  session :off, :except =&gt; %w(foo bar)

  # turn off session management for only the foo and bar actions.
  session :off, :only =&gt; %w(foo bar)

  # the session will only work over HTTPS, but only for the foo action
  session :only =&gt; :foo, :session_secure =&gt; true

  # the session by default uses HttpOnly sessions for security reasons.
  # this can be switched off.
  session :only =&gt; :foo, :session_http_only =&gt; false

  # the session will only be disabled for 'foo', and only if it is
  # requested as a web service
  session :off, :only =&gt; :foo,
          :if =&gt; Proc.new { |req| req.parameters[:ws] }

  # the session will be disabled for non html/ajax requests
  session :off,
    :if =&gt; Proc.new { |req| !(req.format.html? || req.format.js?) }

  # turn the session back on, useful when it was turned off in the
  # application controller, and you need it on in another controller
  session :on
</pre>
<p>
All <a href="ClassMethods.html#M000890">session</a> options described for
<a href="../Base.html#M001145">ActionController::Base.process_cgi</a> are
valid arguments.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000890-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000890-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/session_management.rb, line 82</span>
82:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
83:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">extract_options!</span>
84: 
85:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:disabled</span>] = <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:on</span>)
86:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:disabled</span>] = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">empty?</span>
87:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>] = [<span class="ruby-operator">*</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>]].<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>]
88:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] = [<span class="ruby-operator">*</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>]].<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span>.<span class="ruby-identifier">to_s</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>]
89:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>]
90:           <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;only one of either :only or :except are allowed&quot;</span>
91:         <span class="ruby-keyword kw">end</span>
92: 
93:         <span class="ruby-identifier">write_inheritable_array</span>(<span class="ruby-identifier">:session_options</span>, [<span class="ruby-identifier">options</span>])
94:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000891" class="method-detail">
        <a name="M000891"></a>

        <div class="method-heading">
          <span class="method-name">session=</span><span class="method-args">(*args)</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="ClassMethods.html#M000890">session</a>
</p>
        </div>
      </div>

      <div id="method-M000889" class="method-detail">
        <a name="M000889"></a>

        <div class="method-heading">
          <a href="#M000889" class="method-signature">
          <span class="method-name">session_options</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the hash used to configure the <a
href="ClassMethods.html#M000890">session</a>. Example use:
</p>
<pre>
  ActionController::Base.session_options[:session_secure] = true # session only available over HTTPS
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000889-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000889-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/session_management.rb, line 37</span>
37:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session_options</span>
38:         <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">CgiRequest</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_SESSION_OPTIONS</span>
39:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000888" class="method-detail">
        <a name="M000888"></a>

        <div class="method-heading">
          <a href="#M000888" class="method-signature">
          <span class="method-name">session_store</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the <a href="ClassMethods.html#M000890">session</a> store class
currently used.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000888-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000888-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/session_management.rb, line 30</span>
30:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session_store</span>
31:         <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">CgiRequest</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_SESSION_OPTIONS</span>[<span class="ruby-identifier">:database_manager</span>]
32:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000887" class="method-detail">
        <a name="M000887"></a>

        <div class="method-heading">
          <a href="#M000887" class="method-signature">
          <span class="method-name">session_store=</span><span class="method-args">(store)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Set the <a href="ClassMethods.html#M000890">session</a> store to be used
for keeping the <a href="ClassMethods.html#M000890">session</a> data
between requests. By default, sessions are stored in browser cookies
(<tt>:cookie_store</tt>), but you can also specify one of the other
included stores (<tt>:active_record_store</tt>, <tt>:p_store</tt>,
<tt>:drb_store</tt>, <tt>:mem_cache_store</tt>, or <tt>:memory_store</tt>)
or your own custom class.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000887-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000887-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_controller/session_management.rb, line 24</span>
24:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">session_store=</span>(<span class="ruby-identifier">store</span>)
25:         <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">CgiRequest</span><span class="ruby-operator">::</span><span class="ruby-constant">DEFAULT_SESSION_OPTIONS</span>[<span class="ruby-identifier">:database_manager</span>] =
26:           <span class="ruby-identifier">store</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">CGI</span><span class="ruby-operator">::</span><span class="ruby-constant">Session</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">store</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:drb_store</span> <span class="ruby-operator">?</span> <span class="ruby-value str">&quot;DRbStore&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">store</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">camelize</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">store</span>
27:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>